<?php

use Illuminate\Support\Facades\Route;

Route::group(['middleware' => 'auth:web'], function () {

    Route::redirect('/', 'center/info')->name('center');

    // 基本信息
    Route::group(['prefix' => 'info'], function () {

        Route::get('/')
            ->uses('InfoController@showInfo')
            ->name('center.info');
    });

    // 账号安全
    Route::group(['prefix' => 'security'], function () {

        Route::get('/')
            ->uses('SecurityController@showIndex')
            ->name('center.security');

        // 绑定/修改邮箱
        Route::get('email')
            ->uses('SecurityController@showEmail')
            ->name('center.security.email');

        Route::post('email')
            ->middleware(['throttle:5,1', 'sms-code:web'])
            ->uses('SecurityController@sendVerifyLink');

        // 验证邮箱地址
        Route::get('email-verify/{token}')
            ->uses('SecurityController@emailVerify')
            ->name('center.security.email-verify');

        // 修改密码
        Route::get('password')
            ->uses('SecurityController@showPassword')
            ->name('center.security.password');

        Route::post('password')
            ->uses('SecurityController@changePassword');

        Route::get('login-logs')
            ->uses('SecurityController@showLoginLogs')
            ->name('center.security.login-logs');

    });

    // 账号绑定
    Route::group(['prefix' => 'binds'], function () {

        Route::get('/')
            ->uses('BindsController@showBinds')
            ->name('center.binds');

        Route::get('/bind/{type}')
            ->uses('BindsController@bind')
            ->name('center.binds.bind');

        // 解除账号绑定
        Route::match(['get', 'post'], '/unbind/{type}')
            ->uses('BindsController@unbind')
            ->name('center.binds.unbind');
    });
});